<?php

namespace app\admin\controller;

use think\App;
use think\Request;
use think\facade\Session;
use app\admin\services\AuthentService;

class Role extends Authent
{
    public function __construct(Request $request = null, App $app = null)
    {
        parent::__construct($request, $app);
        $this->AuthentService = new AuthentService();
        global $authstate;
        if(isset($authstate['status']) && $authstate['status'] !=0 ){
            echo json_encode($authstate); die;
        }
    }



    /**
     * @return mixed
     * 首页
     */
    public function index()
    {
        
        return $this->fetch();
    }


    /**
     * @param 管理角色列表
     */
    public function selecsl(){
        $data = $this->AuthentService->lorefk();
        return json($data);
    }


    /**
     * @param 添加角色
     */
    public function add(){
        $data = $this->AuthentService->addtit();
        return json($data);
    }


    /**
     * @param 修改角色
     */
    public function edit(){
        $data = $this->AuthentService->editos();
        return json($data);
    }

    /**
     * @param 角色禁用
     */
    public function jinyong(){
       $data = $this->AuthentService->examine();
        return json($data);
    }


    /**
     * @param 删除角色
     */
    public function del(){
        $data = $this->AuthentService->delect();
        return json($data);
    }


    /**
     * @param 分配权限页面
     */
    public function authtion(){
        $authid = $this->AuthentService->authid();
        $authone = $this->AuthentService->authOne();
        $auths = $authid['data']['rules'];
        $data = explode(',',$auths);
        $this->assign('authone',$authone);
        $this->assign('roleid',$authid);
        $this->assign('rules',$data);
        return $this->fetch();
    }

    /**
     * @param 修改权限
     */
    public function allot(){
        $data = $this->AuthentService->alledit();
        return json($data);
    }

}